<?php

namespace Biz\model\brand;

/**
 * 品牌内容池关联的wiki
 * Class ContentWiki
 * @package Biz\model\brand
 */
class ContentWiki extends \Doraemon\pockets\datebase\BaseDbModel
{
    const _CONFIG_FILE_ = 'db_store';

    const _CONFIG_SELECT_ = 'db_store';

    const _DATABASE_ = 'store';

    const _TABLE_NAME = 'brand_content_wiki';

    const RELATION_NONE = 0; //未操作
    const RELATION_DONE = 1; //已关联
    const RELATION_IGNORE = 2; //忽略
    const RELATION_CANCEL = 3; //取消关联
    const RELATION_MATCH = 4;  //等待关联

    const OPERATION_MODE_AUTO = 1; //自动匹配
    const OPERATION_MODE_CLAIM = 2; //认领
    const OPERATION_MODE_EXTEND = 4; //追加


    public static function getByObjId($brand_id, $obj_id = '')
    {
        return self::select("wiki_id", [
           "obj_id" => $obj_id,
            "brand_id" => $brand_id
        ]);
    }

    public static function getByOIdBidCids($brand_id, $obj_id = '', $cids = [])
    {
        if($cids && is_array($cids)) {
            return self::select("wiki_id", [
                "obj_id" => $obj_id,
                "brand_id" => $brand_id,
                "cid" => $cids,
                "audit_status" => [
                    Content::AUDIT_STATUS_SUCCESS,
                    Content::AUDIT_STATUS_AUTO,
                ],
                "relation" => self::RELATION_DONE
            ]);
        }
        return [];

    }

    // 通过cid 获取数据
    public static function getByCid($cid)
    {
        return self::select("*", [
            "cid" => $cid,
            "relation" => self::RELATION_DONE
        ]);
    }


}